const Joi = require("joi");

const path = Joi.string().pattern(/^[a-z/]{2,20}$/).required();
const name = Joi.string().pattern(/^[a-zA-Z]{2,20}$/).required();
const component = Joi.string().allow(null);
const meta = Joi.string().required();
const title = Joi.string().pattern(/^[\u4e00-\u9fa5a-zA-Z]{2,20}$/).required();
const redirect = Joi.string().allow(null);
const icon = Joi.string().allow(null);
const parentId = Joi.number().required();
const permission = Joi.string().valid("User", "Admin", "SuperAdmin");
const id = Joi.number().integer().min(1).required();

// 定义新增规则对象
exports.add_Schema = {
	body: {
		path,
		name,
		component,
		meta,
		redirect,
		icon,
		title,
		parentId,
		permission
	}
};

//定义修改路由信息的规则对象
exports.update_Schema = {
	body: {
		id,
		path,
		name,
		icon,
		title
	}
};